<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script>
        $(function () {
           $("#username").blur(function () {

               ctxPath="[[@{/}]]";
               var url = ctxPath + "user/count/" +this.value;

               $.get(url,{},function (data) {
                    alert(data.count);
               });
           });
        });
    </script>
</head>
<body>
    <h1>新增用户</h1>
<form action="@{user}" method="post" th:object="${user}">
    <p>用户名:<input type="text" th:field="*{username}"></p>

</form>
</body>
</html>